#ifndef SDB_OBJECT_H_
#define SDB_OBJECT_H_

#include <vmath.h>
#include <xmltree.h>
#include "material.h"

struct isect_point {
	vec3_t pos;
	double dist;
	vec3_t normal;
	vec2_t texcoords;
};

struct object;

struct object *obj_create(void);
void obj_free(struct object *obj);

void obj_print_info(struct object *obj, FILE *fp);

int obj_from_xml(struct object *obj, struct xml_node *xml);
struct xml_node *obj_to_xml(struct object *obj);

int obj_intersect(struct object *obj, ray_t ray, struct isect_point *pt);

int obj_set_name(struct object *obj, const char *name);
const char *obj_get_name(struct object *obj);

int obj_set_type(struct object *obj, const char *type);
const char *obj_get_type(struct object *obj);

void obj_set_material(struct object *obj, struct material *mat);
struct material *obj_get_material(struct object *obj);

void obj_set_xform(struct object *obj, mat4_t xform);
void obj_get_xform(struct object *obj, mat4_t xform);
void obj_get_inv_xform(struct object *obj, mat4_t xform);

/* actual object data are provided by each geometry plugin */
void obj_set_objdata(struct object *obj, void *data);
void *obj_get_objdata(struct object *obj);

#endif	/* SDB_OBJECT_H_ */
